<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function Person(name) {
  this.name = name;
}

Person.prototype.sayHello = function() {
  console.log(`Hello, my name is ${this.name}`);
};

function Student(name, major) {
  Person.call(this, name);
  this.major = major;
}

Student.prototype = Object.create(Person.prototype);
Student.prototype.constructor = Student;
Student.prototype.sayMajor = function() {
  console.log(`My major is ${this.major}`);
};

const john = new Student("John", "Computer Science");
// 1.请解释这段代码的作用。
// 2.john能够调用哪些方法？
// john能够调用sayHello和sayMajor方法。
// 3.如果我们在Student的原型对象上添加一个名为sayHello的方法，会发生什么？
    </script>
</body>
</html>